/*
拓扑排序模板题
*/

#include <bits/stdc++.h>

#define N 105

using namespace std;

vector <int> G[N]; 
queue <int> q;
int cnt[N] = {0};

void topo(){
    //q.push(2);
    while(!q.empty()){
        int tmp = q.front();    q.pop();
        cout << tmp << " ";
        for(int i : G[tmp]){
            cnt[i]--;
            if(cnt[i] == 0){
                q.push(i);
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int tmp;
        while(true){
            cin >> tmp;
            if(tmp == 0)    break;
            else{
                G[i].push_back(tmp);
                cnt[tmp]++;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        if(cnt[i] == 0){
            q.push(i);
        }
    }
    topo();
    return 0;
}